home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / samba-common.config < prev    next >
Encoding:
Text File  |  2007-05-22  |  2.6 KB  |  113 lines

  1. #!/bin/sh -e
  2.  
  3. # Source debconf library.
  4. . /usr/share/debconf/confmodule
  5.  
  6. # Function for grabbing a parameter from an smb.conf file
  7. smbconf_retr() {
  8.     if [ -z "$1" ]; then
  9.         return
  10.     fi
  11.  
  12.     if [ -n "$2" ]; then
  13.         local FILE="$2"
  14.     fi
  15.  
  16.     if [ -z "$FILE" ]; then
  17.         return
  18.     fi
  19.  
  20.     sed -n -e"
  21.         s/^[[:space:]]*\[global\]/\[global\]/i
  22.         /^\[global\]/,/^[[:space:]]*\[/ {
  23.             s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//pi
  24.         }" $FILE \
  25.     | tail -n 1
  26. }
  27.  
  28. FILE=/etc/samba/smb.conf
  29.  
  30. db_title "Samba Server"
  31.  
  32. # We ask the question IFF the config contains complex options that could
  33. # cause us to break the config.
  34. if [ -f "$FILE" ] && grep -v dhcp.conf $FILE \
  35.                      | grep -qEi '\\$|^[[:space:]]*include[[:space:]]*='
  36. then
  37.     db_input high samba-common/do_debconf || true
  38.     db_go
  39. else
  40.     db_set samba-common/do_debconf true
  41. fi
  42.  
  43. # If user doesn't want to use debconf to configure Samba the leave...
  44. db_get samba-common/do_debconf || true
  45. if [ "${RET}" = "false" ]; then
  46.     exit 0
  47. fi
  48.  
  49. # User wants to use debconf, let's continue...
  50.  
  51. # Adjust priority of the question about the workgroup name depending
  52. # on whether a workgroup name has already being specified.
  53. db_get samba-common/workgroup || true
  54. if [ "${RET}" ]; then
  55.     WGPRIORITY=medium
  56. else
  57.     WGPRIORITY=high
  58. fi
  59.  
  60. # Preload any values from the existing smb.conf file
  61. if [ -f $FILE ]; then
  62.     WORKGROUP=`smbconf_retr workgroup`
  63.     if [ "$WORKGROUP" ]; then
  64.         db_set samba-common/workgroup "$WORKGROUP"
  65.     fi
  66.  
  67.     ENCRYPT=`smbconf_retr "encrypt passwords"`
  68.     if [ "$ENCRYPT" ]; then
  69.         ENCRYPT=`echo $ENCRYPT | tr '[A-Z]' '[a-z]'`
  70.         if [ "$ENCRYPT" = "yes" ]; then
  71.             ENCRYPT=true
  72.         elif [ "$ENCRYPT" = "no" ]; then
  73.             ENCRYPT=false
  74.         fi
  75.  
  76.         db_set samba-common/encrypt_passwords "$ENCRYPT"
  77.     fi
  78. fi
  79.  
  80. # Get workgroup name
  81. db_input $WGPRIORITY samba-common/workgroup || true
  82. db_go
  83.  
  84. # Use encrypted passwords?
  85. db_input medium samba-common/encrypt_passwords || true
  86. db_go
  87.  
  88. DHCPPRIORITY=medium
  89. #if [ "$DEBCONF_RECONFIGURE" = 1 ] && [ -f /sbin/dhclient3 ]
  90. #if [ -f /sbin/dhclient3 ]
  91. #then
  92. #    DHCPPRIORITY=high
  93. # TODO: see if we can detect that dhcp3-client is *going* to be installed,
  94. # even if it isn't yet.
  95. #elif dpkg-query -W --showformat='${Status}\n' dhcp3-client | grep ???
  96. # unknown ok not-installed ? 
  97. #    DHCPPRIORITY=high
  98. #fi
  99.  
  100. if [ ! -f $FILE ] || grep -q -i 'wins server' $FILE
  101. then
  102.     # check the values before and after; unset the 'applied' flag
  103.     # if they don't match.
  104.     db_get samba-common/dhcp || true
  105.     OLDDHCP="$RET"
  106.     db_input $DHCPPRIORITY samba-common/dhcp || true
  107.     db_go
  108.     db_get samba-common/dhcp || true
  109.     if [ "$OLDDHCP" != "$RET" ]; then
  110.         db_fset samba-common/dhcp applied false
  111.     fi
  112. fi
  113.